const jwt = require('jsonwebtoken')
const { createNews } = require('../service/news.service')
const { error } = require('../constant/err.type')
const { success } = require("../constant");
class UserController {
    async createNews(ctx, next) {
        const { title, content } = ctx.request.body
        const userId = ctx.state.user.id
        try {
            const res = await createNews({ title, content, userId })
            ctx.body = {
                code: success,
                message: '添加成功'
            }
        } catch (err) {
            ctx.app.emit('error', error, ctx)
        }
    }
}
module.exports = new UserController()
